<template>
  <van-row v-if="user">
    <van-col :span="24">
      <van-image
        width="100"
        height="100"
        :src="user.userImg"
      />
      <div>用户名：{{user.username}}</div>
    </van-col>
  </van-row>
  <van-row v-if="user">
    <van-col :span="24">
      <van-button type="primary" @click="toLogin">去登录</van-button>
    </van-col>
  </van-row>
</template>

<script setup>
import { onMounted, ref , getCurrentInstance } from "vue";

const user = ref(null);

const proxy = getCurrentInstance();

const toLogin = ()=>{
  proxy.$router.push('/login');
}

onMounted(()=>{
  let userJson = window.localStorage.getItem("loginUser");
  if(userJson){
    user.value = JSON.parse(userJson);
  }
})
</script>

<style>
</style>
